    //
    //  EJSClubMessageModel.m
    //  didigo
    //
    //  Created by JS_Coder on 2019/2/24.
    //  Copyright © 2019 lifayu. All rights reserved.
    //

#import "EJSClubMessageModel.h"
@implementation EJSClubMessageModel
- (NSString *)getArrayObjectClassNameForArrayName:(NSString *)arrayName {
    if ([arrayName isEqualToString:@"pics"]) {
        return @"NSString";
    }else if ( [arrayName isEqualToString:@"comments"] ) {
        return @"EJSClubCommentModel";
    }else if ([arrayName isEqualToString:@"momentLove"])
      {
        return @"EJSClubMomentLoveModel";
      }
    return @"";
}

- (CGFloat)rowHeight {
    if (_rowHeight != 0) {
        return ceil(_rowHeight);
    }
    int cols = 3;
    int rows;

    if (self.picTotal.intValue > 0 && self.picTotal.intValue < 4) {
        rows = 1;
    }else if (self.picTotal.intValue > 3 && self.picTotal.intValue < 7) {
        rows = 2;
    }else if (self.picTotal.intValue > 6){
        rows = 3;
    }else {
        rows = 0;
    }

    CGFloat titleHeight = 26 + CommonMargin;
    _rowHeight += titleHeight;

    CGFloat contentHeight = [self.content sizeWithFont:CHINESE_PingFangRegular(15) maxSize:CGSizeMake(ScreenWidth - ClubMargin, 110)].height + CommonMargin;

    _rowHeight += contentHeight;

    CGFloat picViewHeight = ((((ScreenWidth - ClubMargin) - (cols - 1) * 5) / cols) * rows) + (rows * (CommonMargin * 0.5));

    if (_pics.count == 1) {
        picViewHeight = 160;
    }
    self.imagesHeight = picViewHeight;

    CGFloat picHeight = picViewHeight + CommonMargin;
    _rowHeight += picHeight;

    CGFloat middleHeight = 35 + CommonMargin;
    _rowHeight += middleHeight;

    CGFloat loveViewHeight = 35;

    if ([self.loveTotal isEqualToString:@"0"]) {
        loveViewHeight = 0;
    }

    _likesHeight = loveViewHeight;
    _rowHeight += loveViewHeight + CommonMargin;

    CGFloat commentsHeight = 0;

    if (_comments.count > 3) {
        commentsHeight = 3 * 30;
    }else if (_comments.count == 0) {
        commentsHeight = 0;
    }else {
        commentsHeight = _comments.count * 30;
    }
    
    self.commentsHeight = commentsHeight ;
    
    _rowHeight += commentsHeight + CommonMargin;
    _rowHeight += CommonMargin;

    return _rowHeight;
}

@end
